package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.AnalysisManageRightMenu;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2018-11-26 15:05:39
 */
@Repository
public class AnalysisManageRightMenuDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(AnalysisManageRightMenuDao.class);

    public AnalysisManageRightMenu insert(final AnalysisManageRightMenu analysisManageRightMenu) {
        insert("AnalysisManageRightMenu.insert", analysisManageRightMenu);
        return analysisManageRightMenu;
    }

    public Boolean updateInfoById(final AnalysisManageRightMenu analysisManageRightMenu) {
        return update("AnalysisManageRightMenu.updateInfoById", analysisManageRightMenu) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("AnalysisManageRightMenu.updateInfoByQuery", query) > 0;
    }

    public AnalysisManageRightMenu selectById(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return queryForObject("AnalysisManageRightMenu.selectById", query);
    }

    public List<AnalysisManageRightMenu> selectByQuery(final Query query) {
        return queryForList("AnalysisManageRightMenu.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("AnalysisManageRightMenu.countByQuery", query);
    }

    public Boolean deleteById(final Integer id) {
        AnalysisManageRightMenu analysisManageRightMenu = new AnalysisManageRightMenu();
        analysisManageRightMenu.setDeleteFlag(1);
        analysisManageRightMenu.setId(id);

        return update("AnalysisManageRightMenu.updateInfoById", analysisManageRightMenu) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("AnalysisManageRightMenu.deleteById", query) > 0;
    }
}